<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<!DOCTYPE html>
<html>
<c:set value="${pageContext.request.contextPath }" var="cPath" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<c:set var="curMsg" value="${ empty param.msg? requestScope.msg:param.msg}" />
<SCRIPT type="text/javascript">
<c:if test="${!empty curMsg }">
alert("${curMsg }");
</c:if>
	
	function deleteShop(){
		var form = document.getElementById("shopForm");
		form.action = "${cPath}/shopDelete.do";
		form.submit();
	}
	
	function codeAddress() {
		   var geocoder = new google.maps.Geocoder();
		   
		    var address = document.getElementById("address").value;
		    geocoder.geocode( { 'address': address}, function(results, status) {
		      if (status == google.maps.GeocoderStatus.OK) {
		        document.getElementById("lat").value = results[0].geometry.location.lat();
		        document.getElementById("lng").value = results[0].geometry.location.lng();
		      } else {
		        alert("Geocode was not successful for the following reason: " + status);
		      }
		    });
		  }
</SCRIPT>
</head>
<body>
<form id="shopForm" action="${cPath }/shopUpdate.do" method="get">
<div align="center">
<table>
	<tr>
		<th>상점번호</th>
		<td>
			<input type="text" name="sh_no" value="${shop.sh_no }" />
		</td>
	</tr>
	<tr>
		<th>상점이름</th>
		<td>
			<INPUT type="text" name="sh_name" value="${shop.sh_name }"/>
		</td>
	</tr>
	<tr>
		<th>상점비밀번호</th>
		<td>
			<INPUT type="text" name="sh_pass" value=""/>
		</td>
	</tr>
	<tr>
		<th>상점전화번호</th>
		<td>
			<INPUT type="text" name="sh_phone" value="${shop.sh_phone }"/>
		</td>
	</tr>
	<tr>
		<th>상점주소</th>
		<td>
			<INPUT type="text"  id="address" name="sh_add" value="${shop.sh_add }"/>
			<input type="button" value="주소등록" onclick="codeAddress()"/>
		</td>
	</tr>
	<tr>
		<th>상점메세지</th>
		<td>
			<input type="text" name="sh_message" value="${shop.sh_message }"/>
		</td>
	</tr>
	<tr>
		<th>상점사진</th>
		<td>
			<input type="file" name="sh_photo" value="${shop.sh_photo }"/><br/>			
			<img src="data:image/jpeg;base64, ${shop.sh_photoStr }" />
		</td>
	</tr>
	<tr>
		<td colspan="2">
		<INPUT type="submit" value="수정하기" /> 
		<INPUT type="button" value="탈퇴하기" onclick="deleteShop()" /> 
		<INPUT type="button" value="목록으로"
			onclick="window.location.href='${cPath}/shopList.do'" />
		</td>
	</tr>
</table>
<input id="lat" type="text" name="sh_latitude">
<input id="lng" type="text" name="sh_longitude">
</div>
</form>
</body>
</html>